/*
 * instr_list.h
 *
 * Group: Fantastic Five
 * Date: 4/24/08
 *
 * Description: Header file for linked list of instructions
 */

#include <stdio.h>
#include <stdlib.h>
#include "token_list.h"

/* Define instruction */
struct instr
{
    struct instr * next;
    struct instr * prev;

    enum opcode op;

    union value v1; /* value of first operand, if int or float */
    enum lexeme type1; /* type of first operand */

    union value v2; /* value of second operand, if int or float */
    enum lexeme type2; /* type of second operand */
    
    int linenum;
};

/* Define instruction list */
struct instr_list
{
    struct instr *head;
    struct instr *tail;
    int count;
};

/* mallocs and initializes a new instr list */
struct instr_list * new_instr_list();

/* mallocs and initializes a new instr */
struct instr * new_instr(int, enum opcode, union value, enum lexeme, union value, enum lexeme);

/* Pushes instr onto back of instruction list */
void push_instr(struct instr *, struct instr_list *);

/* Pops off instr at beginning of instruction list and returns it */
struct instr * pop_instr(struct instr_list *);

/* Removes instr rem from list */
void remove_instr(struct instr *, struct instr_list *);

/* Checks to see if list contains instructions, return 1 if empty, 0 if not */
int no_instr(struct instr_list *);

/* Removes all instructions from list */
void empty_instr_list(struct instr_list *);
